<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //then执行 return的值将会作为下一个then的参数
        let p = new Promise((resolve, reject) => {
            resolve('成功')
        })
        p.then().then(res => {
            return '12'
        }).then(res => {
            console.log(res)//12
        })


        let p2 = new Promise((resolve, reject) => {
            resolve('成功')
        })
        p2.then().then(res => {
            return new Promise((resolve, reject) => {
                resolve('成功2')
            })
        }).then(res => {
            console.log(res)//成功2
        })

        // 失败的话 也被调用对应是失败的 不断向下
        let p3 = new Promise((resolve, reject) => {
            resolve('成功')
        })
        p2.then().then(res => {
            return new Promise((resolve, reject) => {
                reject('失败')
            })
        }).then(res => {
            console.log(res)
        }, err => {
            console.log(err)//失败
        })



    </script>

</body>

</html>